
package mars.activity;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;

public class Help extends Activity{
private Button return0;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help);
	    return0=(Button)findViewById(R.id.return0);
        return0.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0) {
				// TODO Auto-generated method stub				
			System.exit(0);
			}
			});
	}   
	public boolean onCreateOptionsMenu(Menu menu) {
		// TODO Auto-generated method stub
		menu.add(0,1,1,R.string.exit);
		menu.add(0,2,2,R.string.options);
		menu.add(0,3,3,R.string.help);
		return super.onCreateOptionsMenu(menu);
	}
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		if(item.getItemId()==1){
			AlertDialog dialog = new AlertDialog.Builder(Help.this)  
            .setIcon(android.R.drawable.btn_star_big_on)  
            .setTitle(R.string.tuichu)  
          .setPositiveButton(R.string.determine, onclick)  
            .setNegativeButton(R.string.cancel,  onclick).create();  
				dialog.show();
		}else if(item.getItemId()==2){
			item.setIntent(new Intent(this, Options.class));
		}else if(item.getItemId()==3){
			item.setIntent(new Intent(this, Help.class));
		}
		return super.onOptionsItemSelected(item);
	}
	OnClickListener onclick = new OnClickListener() { 
        public void onClick(DialogInterface dialog, int which) {  
            switch (which) {  
                case Dialog.BUTTON_NEGATIVE:  
                    break;  
                case Dialog.BUTTON_POSITIVE:
                	Intent startMain = new Intent(Intent.ACTION_MAIN);
        			startMain.addCategory(Intent.CATEGORY_HOME);
        			startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        			startActivity(startMain);
        			System.exit(0);
                    break;  
            } 
        }
    };
}

